function checkUsername(name,id) {
    var reg =/^[\u4e00-\u9fa5]*$/;
    if(!reg.test(name))
    {
        alertThis(id,'用中文名哦同学~');
        return '';
    }
    else
    {
        return name;
    }
}
function checkNum(number,id) {
    var reg= /^([0-9]+)$/;
    if(!reg.test(number))
    {
        alertThis(id,'学号只允许是数字哦(*^__^*)~');
        return '';
    }
    else
    {
        reg=/\d{8}/;
        if(!reg.test(number))
        {
            alertThis(id,'学号至少8位哦(*^__^*)~');
            return '';
        }
        else return number;
    }

}
function checkPass() {
    var pass1=$('#r_pass1').val();
    var pass2=$('#r_pass2').val();
    if(pass1==''||pass2=='')
        return;

    if(pass1!=pass2)
    {
        alertThis('#r_pass1','Oops~');
        alertThis('#r_pass2','两次输入密码不一致~');
        $('#r_pass1').val('');
        $('#r_pass2').val('');
    }
    else
    {
        var reg=/^(((?=.*[a-zA-Z])(?=.*[0-9]))|((?=.*[a-zA-Z])(?=.*[~!@#$%^&*()_+`\-=\{}:";<>?,.\/]))|((?=.*[0-9])(?=.*[~!@#$%^&*()_+`\-=\{}:";<>?,.\/]))|((?=.*[a-zA-Z])(?=.*[0-9])(?=.*[~!@#$%^&*()_+`\-=\{}:";<>?,.\/])))[^']{8,16}$/;
        if(!reg.test(pass1))
        {
            alertThis('#r_pass1','Oops~密码长度必须在8~16之间');
            alertThis('#r_pass2','至少包含数字、字母、特殊符号这三种的两种');
            $('#r_pass1').val('');
            $('#r_pass2').val('');
        }
        else
        {
            $('#r_pass1').val(pass1);
            $('#r_pass2').val(pass2);
        }
    }
}
function checkSchoolname(name,id) {
    var reg =/^[^\x00-\xff]*$/;
    if(!reg.test(name))
    {
        alertThis(id,'学校名字格式不正确╭(╯^╰)╮至少得是中文吧~');
        return '';
    }
    else
    {
        return name;
    }
}
function checkEmail(email,id) {
    var reg = /\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}/;
    if(!reg.test(email))
    {
        alertThis(id,'邮箱格式不正确TAT~');
        return '';
    }
    else{
        return email;
    }
}
function checkNick(name,id) {
    var reg = new RegExp("[`@#$^&*()=|{}':;',\\[\\].<>/?！@#￥……&*（）——|{}‘；：”“']");
    if(reg.test(name))
    {
        alertThis(id,'起昵称的方式简单点~不能含有特殊字符哦~');
        return '';
    }
    else{
        return name;
    }

}
function checkPhonenum(num,id) {
    var reg = /(13\d|14[57]|15[^4,\D]|17[678]|18\d)\d{8}|170[059]\d{7}/;
    var reg2=/^1\d{10}$/;
    if(!reg.test(num)||!reg2.test(num))
    {
        alertThis(id,'手机号格式不正确(⊙o⊙)~');
        return '';
    }
    else{
        return num;
    }
}
function clearThis(id) {
    var lable;
    switch (id)
    {
        case '#r_email':
            lable='登录邮箱';
            break;
        case '#r_name':
            lable='姓名';
            break;
        case '#r_num':
            lable='学号';
            break;
        case '#r_school':
            lable='学校';
            break;
        case'#r_phone':
            lable='手机号码';
            break;
        case '#r_nick':
            lable='昵称';
            break;
        case '#r_pass1':
            lable='密码';
            break;
        case '#r_pass2':
            lable='确认密码';
            break;
        case '#r_verify':
            lable = '验证码(区分大小写)';
    }
    $(id).attr('class','radius');
    $(id).attr('placeholder',lable);
    $('#button_submit').html('注册').attr('class','radius button');
}
function alertThis(id,msg) {
    $(id).attr('class','radius alert-box alert');
    $(id).attr('placeholder',msg);
}
function submit_form() {
    var idarr = [];
    var cansubmit=true;
    idarr[1]='#r_name';
    idarr[5]='#r_email';
    idarr[2]='#r_num';
    idarr[3]='#r_school';
    idarr[8]='#r_phone';
    idarr[4]='#r_nick';
    idarr[6]='#r_pass1';
    idarr[7]='#r_pass2';
    idarr[8]='#r_verify';
    for(var i=1;i<idarr.length;i++) {
        if ($(idarr[i]).val() == '') {
            $(idarr[i]).attr('class', 'radius alert-box alert');
            var lable;
            switch (idarr[i]) {
                case '#r_email':
                    lable = '登录邮箱';
                    break;
                case '#r_name':
                    lable = '姓名';
                    break;
                case '#r_num':
                    lable = '学号';
                    break;
                case '#r_school':
                    lable = '学校';
                    break;
                case'#r_phone':
                    lable = '手机号码';
                    break;
                case '#r_nick':
                    lable = '昵称';
                    break;
                case '#r_pass1':
                    lable = '密码';
                    break;
                case '#r_pass2':
                    lable = '确认密码';
                    break;
                case '#r_verify':
                    lable = '验证码';
            }
            $(idarr[i]).attr('placeholder', lable + '不能为空！');
            $('#button_submit').attr('class','radius button warning').html('表格不能有空');
            cansubmit = false;
            break;
        }
    }
    if(cansubmit) {
        $('#register_form').append($("<input type='hidden' name='getaccess' value='register_form'>")).submit();
        $('#button_submit').attr('class','radius button success').html('正在提交');
    }

}